package com.gordon.tips.filter;

import java.io.IOException;
import java.util.List;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.gordon.tips.domain.Item;
import com.gordon.tips.log.Logger;
import com.gordon.tips.log.LoggerImpl;
import com.gordon.tips.service.GameService;

/**
 * Game Data list
 * 2011.12.15 14:27
 * @author Gordon Hwang
 *
 */
public class GameDataFilter implements Filter {
	//logger component
	private static Logger logger = new LoggerImpl(GameDataFilter.class);
	private GameService gameService;

	public void destroy() {
		

	}

	public void doFilter(ServletRequest req, ServletResponse resp,
			FilterChain chain) throws IOException, ServletException {
		// TODO Auto-generated method stub
		List<Item>items=gameService.listItems(0, 100);
		req.setAttribute("items", items);
		logger.debug("game data listing..size:"+items.size());
		chain.doFilter(req, resp);
	}

	public void init(FilterConfig arg0) throws ServletException {
		

	}

	public GameService getGameService() {
		return gameService;
	}

	public void setGameService(GameService gameService) {
		this.gameService = gameService;
	}
	
	

}
